//
//  PersonalHomeViewController.m
//  Btpin
//
//  Created by Vic on 2019/3/12.
//  Copyright © 2019 Vic. All rights reserved.
//


#import "PersonalHomeViewController.h"
#import "AppDelegate.h"
#import "JobCell.h"
#import "PersonalHomeHeaderView.h"
#import "HomePulldownView.h"
#import "HomeCustomNavigationBarView.h"
#import "SearchJobCompanyViewController.h"
#import "JobDetailViewController.h"
#import "PMineInviteFriendViewController.h"
//#import "NewsViewController.h"
#import "GeneralWebViewViewController.h"
#import "PMineBusinessCardViewController.h"

#import "LYRecomendCell.h"
#import "LYDropDownView.h"

#import "QRCodeViewController.h"

#import "SigninViewController.h"
#import "LYStackLayout.h"
#import "JobCollectionViewCell.h"
#import "TransitionToDetailVC.h"
#import "HomeBallHeaderView.h"

#import "PHomeFilterView.h"
#import "PMineCreditEvaluationViewController.h"
#import "PMineResumeInfoModel.h"


@interface PersonalHomeViewController ()<PersonalHomeHeaderViewDelegate, UIScrollViewDelegate, HomeCustomNavigationBarViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UINavigationControllerDelegate, HomeBallHeaderViewDelegate, PHomeFilterViewDelegate>
{
    NSMutableArray *itemDataArray;
    NSMutableArray *ballDataArray;
    CGFloat offsetY;
    
    HomeBallHeaderView *headerBallView;
    
    HomeCustomNavigationBarView *navigationBar;
    NSInteger currentPage;
    
    NSString *recommend;
    NSString *job_category;
    NSString *district;
    NSString *scale;
    NSString *finance;
    NSString *experience;
    NSString *education;
    NSString *trade;
    NSString *wage;
    NSString *keyword;
    NSString *lat;
    NSString *lng;
    
    PHomeFilterView *PHFView;
}
@end

@implementation PersonalHomeViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
//    if (offsetY == 0) {
//        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
//    } else {
//        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
//    }
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    
    if (headerBallView) {
        [headerBallView animationStart];
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationController.delegate = self;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    
    if (PHFView && PHFView.filterShowFlag) {
        [PHFView dismissView];
    }
    
    if (headerBallView) {
        [headerBallView animationStop];
    }
    
//    if (self.navigationController.delegate == self) {
//        self.navigationController.delegate = nil;
//    }
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(loadDataAndToTop) name:NotificationForPersonalJobRefresh object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(loadDataForBaseForJobIntentionChange) name:NotificationFor_JobIntention_Change object:nil];
    
    itemDataArray = [NSMutableArray arrayWithCapacity:0];
    ballDataArray = [NSMutableArray arrayWithCapacity:0];
    offsetY = 0;
    currentPage = 1;
    recommend = @"";
    job_category = @"";
    district = @"";
    scale = @"0";
    finance = @"0";
    experience = @"0";
    education = @"0";
    trade = @"0";
    wage = @"0";
    keyword = @"";
    lat = @"";
    lng = @"";
    
    [self loadDataForBase];
//    [self initUI];
//    [self getCompanyList];
}
- (void)loadDataForBase {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    
    [BaseNetManager requestWithMethod:POST path:PersonMineResume_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            PMineResumeInfoModel *infoModel = [[PMineResumeInfoModel alloc] init];
            [infoModel setValuesForKeysWithDictionary:data];
            
            if (infoModel.intentionModel.jobs.count) {
                PublicCategoryElementModel *model1 = infoModel.intentionModel.jobs.firstObject;
                NSArray *array = [model1.id componentsSeparatedByString:@"."];
                if (array.lastObject && [array.lastObject length] && ![array.lastObject isEqualToString:@"."]) {
                    NSString *jid = array.lastObject;
                    if (![self->job_category isEqualToString:jid]) {
                        self->job_category = jid;
                    }
                }
                for (PublicCategoryElementModel *model111 in infoModel.intentionModel.jobs) {
                    PublicCategoryElementModel *ballModel = [[PublicCategoryElementModel alloc] init];
                    ballModel.name = model111.name;
                    ballModel.id = model111.id;
                    ballModel.canTapFlag = YES;
                    [self->ballDataArray addObject:ballModel];
                }
            }
        }
        SVPHUDDismiss;
        [self initUI];
        [self getCompanyList];
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDDismiss;
        [self initUI];
        [self getCompanyList];
    }];
}
- (void)loadDataForBaseForJobIntentionChange {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    
    [BaseNetManager requestWithMethod:POST path:PersonMineResume_URL params:dic successBlock:^(NSDictionary * _Nonnull responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            PMineResumeInfoModel *infoModel = [[PMineResumeInfoModel alloc] init];
            [infoModel setValuesForKeysWithDictionary:data];
            
            if (infoModel.intentionModel.jobs.count) {
                PublicCategoryElementModel *model1 = infoModel.intentionModel.jobs.firstObject;
                NSArray *array = [model1.id componentsSeparatedByString:@"."];
                if (array.lastObject && [array.lastObject length] && ![array.lastObject isEqualToString:@"."]) {
                    NSString *jid = array.lastObject;
                    if (![self->job_category isEqualToString:jid]) {
                        self->job_category = jid;
                    }
                }
                
                if (self->ballDataArray && self->ballDataArray.count) {
                    [self->ballDataArray removeAllObjects];
                }
                for (PublicCategoryElementModel *model111 in infoModel.intentionModel.jobs) {
                    PublicCategoryElementModel *ballModel = [[PublicCategoryElementModel alloc] init];
                    ballModel.name = model111.name;
                    ballModel.id = model111.id;
                    ballModel.canTapFlag = YES;
                    [self->ballDataArray addObject:ballModel];
                }
            }
            
            NSMutableArray *ballArray = [NSMutableArray arrayWithCapacity:0];
            ballArray = [self loadCategoryForBall];
            [self->headerBallView reloadDataForBallData:ballArray];
        }
        SVPHUDDismiss;
        [self getCompanyList];
    } failurBlock:^(NSError * _Nonnull error) {
        SVPHUDError(NetErrorAlertText);
    }];
}
- (void)loadDataAndToTop {
    currentPage = 1;
    if (self.cCollectionView.contentOffset.y !=0) {
        [self.cCollectionView setContentOffset:CGPointMake(0, 0) animated:YES];
    }
    [self getCompanyList];
}
- (void)getCompanyList {
    self.noDataView.hidden = YES;
    if (!Signin) {
        job_category = @"";
    }
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:recommend forKey:@"recommend"];
    [dic setObject:job_category forKey:@"job_category"];
    [dic setObject:district forKey:@"district"];
    [dic setObject:scale forKey:@"scale"];
    [dic setObject:finance forKey:@"finance"];
    [dic setObject:experience forKey:@"experience"];
    [dic setObject:education forKey:@"education"];
    [dic setObject:trade forKey:@"trade"];
    [dic setObject:wage forKey:@"wage"];
    [dic setObject:keyword forKey:@"keyword"];
    [dic setObject:lat forKey:@"lat"];
    [dic setObject:lng forKey:@"lng"];
    [dic setObject:[NSString stringWithFormat:@"%ld", (long)currentPage] forKey:@"page"];
    [dic setObject:PageSize forKey:@"number"];
    
    [BaseNetManager requestWithMethod:POST path:JobGetLists_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if (self->currentPage==1) {
                    if (self->itemDataArray.count) {
                        [self->itemDataArray removeAllObjects];
                    }
                }
                for (NSDictionary *dic in data) {
                    CompanyJobModel *model = [[CompanyJobModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    [self->itemDataArray addObject:model];
                }
                self.noDataView.hidden = YES;
                
                [self.cCollectionView.mj_footer endRefreshing];
                [self.cCollectionView reloadData];
            }
            if (self->itemDataArray.count) {
            } else {
                self.noDataView.hidden = NO;
                [self.noDataView vcNilStatusType:VCNilStatusTypeOfJobNoData superView:self.view];
            }
            SVPHUDDismiss;
        } else {
            NSString *str = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            SVPHUDError(str);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (NSMutableArray *)loadCategoryForBall {
    for (PublicCategoryElementModel *tempMpdel in [DataToolsControl sharedManager].allCategoryInfoModel.jobCatsArrayForOneLevel) {
        if (tempMpdel.jobCatsArrayForTworThreeLevel.count) {
            for (PublicCategoryElementModel *tempMpdel111 in tempMpdel.jobCatsArrayForTworThreeLevel) {
                
                BOOL addFlag = YES;
                for (PublicCategoryElementModel *guolvModel in ballDataArray) {
                    if ([guolvModel.name isEqualToString:tempMpdel111.name]) {
                        addFlag = NO;
                        break;
                    }
                }
                if (addFlag) {
                    [ballDataArray addObject:[tempMpdel111 copy]];
                }
            }
        }
    }
    return ballDataArray;
}
- (void)initUI {
    self.view.backgroundColor = THEMECOLOR_OF_GRAY;
    CGRect frame = self.noDataView.frame;
    frame.origin.y += 420*Scale;
    self.noDataView.frame = frame;
    
    NSMutableArray *ballArray = [NSMutableArray arrayWithCapacity:0];
    ballArray = [self loadCategoryForBall];
    
    headerBallView = [[HomeBallHeaderView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, ScalePS(415)) dataArray:ballArray target:self idType:TabBarTypeOfPersonal];
    headerBallView.userInteractionEnabled = YES;
    
    LYStackLayout *layout = [[LYStackLayout alloc]init];
    //卡片的边界设置
    layout.layoutMargin =  UIEdgeInsetsMake(10.0, 0.0, 0.0, 0.0);
    //卡片大小
    layout.itemCellSize = CGSizeMake(WIDTH, ScalePS(130));
    //两个卡片间的距离
    layout.topReveal = ScalePS(120);
    //头视图高度
    layout.headerHeight = ScalePS(415);
    
    self.cCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, HeightOfStatusBarAndNavigationBar, WIDTH, HEIGHT-HeightOfTabBar-HeightOfStatusBarAndNavigationBar) collectionViewLayout:layout];
//    self.cCollectionView.backgroundColor = COLOR_OF_CLEAR;
    self.cCollectionView.backgroundColor = COLOR_OF_WHITE;
    self.cCollectionView.showsHorizontalScrollIndicator = NO;
    self.cCollectionView.showsVerticalScrollIndicator = NO;
    self.cCollectionView.delegate = self;
    self.cCollectionView.dataSource = self;
    [self.view addSubview:self.cCollectionView];
    
    [self.cCollectionView registerClass:[JobCollectionViewCell class] forCellWithReuseIdentifier:isCellID];
    
    [self.cCollectionView addSubview:headerBallView];
//    self.cCollectionView.contentInset = UIEdgeInsetsMake(0, 0, ScalePS(390), 0);
    
    if (@available(iOS 11.0, *)) {
        self.cCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    __weak __typeof(self)weakSelf = self;
    self.cCollectionView.mj_footer = [MJRefreshAutoFooter footerWithRefreshingBlock:^{
        self->currentPage++;
        [weakSelf.cCollectionView.mj_footer beginRefreshing];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakSelf getCompanyList];
        });
    }];
    
    navigationBar = [[HomeCustomNavigationBarView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HeightOfStatusBarAndNavigationBar) target:self];
    navigationBar.offsetY = 0;
    [self.view addSubview:navigationBar];
    
    PHFView = [[PHomeFilterView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT) target:self];
    [[UIApplication sharedApplication].keyWindow addSubview:PHFView];
}
- (void)homeCustomNavigationBarViewQRCode {
    if (Signin) {
        QRCodeViewController *QRCVC = [[QRCodeViewController alloc] init];
        QRCVC.pushVCType = VCPushTypeOfHome;
        QRCVC.edit = ^(BOOL editFlag) {
            
        };
        QRCVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:QRCVC animated:YES];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
        }];
    }
}
- (void)homeBallHeaderViewTap:(HomeLinkType)homeLinkType {
    if (!Signin) {
        [SharedApp showViewController:TabBarTypeOfSignin];
    }
    switch (homeLinkType) {
        case HomeLinkTypeOfBusinessCard: {
            PMineBusinessCardViewController *PMBCVC = [[PMineBusinessCardViewController alloc] init];
            PMBCVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:PMBCVC animated:YES];
        } break;
        case HomeLinkTypeOfInvite: {
            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
            GWVC.showType = GeneralWebViewTypeOfInviteFriend;
            GWVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:GWVC animated:YES];
        } break;
        case HomeLinkTypeOfCreditHashRate: {
            PMineCreditEvaluationViewController *PMCEVC = [[PMineCreditEvaluationViewController alloc] init];
            PMCEVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:PMCEVC animated:YES];
        } break;
        default:
            break;
    }
}
- (void)homeBallHeaderViewBallPointTap:(NSString *)pointId pointText:(nonnull NSString *)pointText {
    NSArray *array = [pointId componentsSeparatedByString:@"."];
    if (array.lastObject && [array.lastObject length] && ![array.lastObject isEqualToString:@"."]) {
        NSString *jid = array.lastObject;
        if (![job_category isEqualToString:jid]) {
            job_category = jid;
            currentPage = 1;
            [self getCompanyList];
        }
    }
}
#pragma mark -- UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return  itemDataArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    JobCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:isCellID forIndexPath:indexPath];
    
    CompanyJobModel *model = itemDataArray[indexPath.row];
    [cell reloadDataModel:model indexPath:indexPath];
    
    return cell;
}
#pragma mark -- UICollectionViewDelegateFlowLayout
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.selectedIndexPath = indexPath;
    
    UIColor *bgColor = THEMECOLOR_OF_ORANGE;
//    switch (indexPath.row%5) {
//        case 0: {
//            bgColor = RGB(255, 118, 108);
//        } break;
//        case 1: {
//            bgColor = RGB(187, 104, 252);
//        } break;
//        case 2: {
//            bgColor = RGB(255, 137, 67);
//        } break;
//        case 3: {
//            bgColor = RGB(2, 168, 252);
//        } break;
//        case 4: {
//            bgColor = RGB(254, 187, 57);
//        } break;
//        default:
//            break;
//    }
    
    CompanyJobModel *model = itemDataArray[indexPath.row];
    JobDetailViewController *JDVC = [[JobDetailViewController alloc] init];
    JDVC.id = model.id;
    JDVC.bgColor = bgColor;
    JDVC.showSettingFlag = NO;
    JDVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:JDVC animated:YES];
}
#pragma mark UINavigationControllerDelegate methods
//- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
//    if ([fromVC isKindOfClass:[PersonalHomeViewController class]] && [toVC isKindOfClass:[JobDetailViewController class]]) {
//        TransitionToDetailVC *transitionVC = [[TransitionToDetailVC alloc] init];
//        return transitionVC;
//    } else {
//        return nil;
//    }
//}

- (void)homeCustomNavigationBarViewFilter {
    if (PHFView.filterShowFlag) {
        [PHFView dismissView];
    } else {
        [PHFView showView];
    }
}
- (void)homeCustomNavigationBarViewSearch {
    NSLog(@"search");
    SearchJobCompanyViewController *SJCVC = [[SearchJobCompanyViewController alloc] init];
    SJCVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:SJCVC animated:YES];
}
- (void)personalHomeHeaderViewBannerCarouselTap:(NSString *)temp {
    NSLog(@"%@", temp);
}
- (void)personalHomeHeaderViewNewCarouselTap:(ArticleItemModel *)model {
    NSLog(@"new轮播");
    if (model && model.url) {
        GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
        GWVC.showType = GeneralWebViewTypeOfNews;
        GWVC.url = model.url;
        GWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:GWVC animated:YES];
    }
}
- (void)personalHomeHeaderViewNewInvitationTap {
    GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
    GWVC.showType = GeneralWebViewTypeOfInviteFriend;
    GWVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:GWVC animated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.cCollectionView) {
        navigationBar.offsetY = scrollView.contentOffset.y;
        offsetY = scrollView.contentOffset.y;
    }
}
- (void)pHomeFilterViewOKInfo:(NSDictionary *)dic {
    if (dic && dic.allKeys.count) {
        NSString *str = [NSString stringWithFormat:@"%@%@-%@%@-%@%@", dic[@"province"], dic[@"provinceid"], dic[@"city"], dic[@"cityid"], dic[@"area"], dic[@"areaid"]];
        NSLog(@"%@", str);
        
        if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
            [itemDataArray removeAllObjects];
        }
        if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
            district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
//            navigationBar.city = dic[@"province"];
        } else {
            district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
//            navigationBar.city = dic[@"city"];
        }
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)pHomeFilterViewBaseInfoOkWage:(NSString *)wage1 experience:(NSString *)experience1 education:(NSString *)education1 scale:(NSString *)scale1 finance:(NSString *)finance1 trade:(NSString *)trade1 {
    if (wage1 && wage1.length) {
        if (wage && (![wage isEqualToString:wage1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            wage = wage1;
        }
    }
    if (experience1 && experience1.length) {
        if (experience && (![experience isEqualToString:experience1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            experience = experience1;
        }
    }
    if (education1 && education1.length) {
        if (education && (![education isEqualToString:education1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            education = education1;
        }
    }
    if (scale1 && scale1.length) {
        if (scale && (![scale isEqualToString:scale1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            scale = scale1;
        }
    }
    if (finance1 && finance1.length) {
        if (finance && (![finance isEqualToString:finance1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            finance = finance1;
        }
    }
    if (trade1 && trade1.length) {
        if (trade && (![trade isEqualToString:trade1])) {
            if (itemDataArray.count) {
                [itemDataArray removeAllObjects];
            }
            trade = trade1;
        }
    }
    
    if (itemDataArray.count) {
        
    } else {
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)hiddenNoDataView {
    if (itemDataArray.count) {
        self.noDataView.hidden = YES;
    } else {
        self.noDataView.hidden = NO;
    }
}

- (void)toSignIn {
    [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
        if (signinFlag) {
            
        }
    }];
}

@end











/*
#import "PersonalHomeViewController.h"
#import "JobCell.h"
#import "PersonalHomeHeaderView.h"
#import "HomePulldownView.h"
#import "HomeCustomNavigationBarView.h"
#import "SearchJobCompanyViewController.h"
#import "JobDetailViewController.h"
#import "SelcetCityViewController.h"
#import "PMineInviteFriendViewController.h"
//#import "NewsViewController.h"
#import "GeneralWebViewViewController.h"

#import "LYRecomendCell.h"
#import "LYDropDownView.h"

#import "LYRecomendView.h"
#import "LYCompanyView.h"
//#import "LYAreaView.h"
#import "PSAreaView.h"
#import "LYClaimView.h"
#import "QRCodeViewController.h"
#import "HomeFilterViewController.h"

#import "SigninViewController.h"

@interface PersonalHomeViewController ()<UITableViewDelegate, UITableViewDataSource, PersonalHomeHeaderViewDelegate, UIScrollViewDelegate, HomeCustomNavigationBarViewDelegate, SelcetCityViewControllerDelegate, LYDropDownViewDelegate>
{
    NSMutableArray *itemDataArray;
    CGFloat offsetY;
    
    NSMutableArray *recomendDataArray;
    NSMutableArray *areaDataArray;
    NSMutableArray *companyDataArray;
    NSMutableArray *claimDataArray;
    LYDropDownView *dropView;
    
    HomeCustomNavigationBarView *navigationBar;
    NSInteger currentPage;
    
    NSString *recommend;
    NSString *job_category;
    NSString *district;
    NSString *scale;
    NSString *finance;
    NSString *experience;
    NSString *education;
    NSString *trade;
    NSString *wage;
    NSString *keyword;
    NSString *lat;
    NSString *lng;
}
@property (nonatomic, strong) UITableView *jobTableView;
@end

@implementation PersonalHomeViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    if (offsetY == 0) {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
    } else {
        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    }
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(loadDataAndToTop) name:NotificationForPersonalJobRefresh object:nil];
    
    itemDataArray = [NSMutableArray arrayWithCapacity:0];
    offsetY = 0;
    currentPage = 1;
    recommend = @"";
    job_category = @"";
    district = @"";
    scale = @"";
    finance = @"";
    experience = @"";
    education = @"";
    trade = @"";
    wage = @"";
    keyword = @"";
    lat = @"";
    lng = @"";
    
    [self loadLocalData];
    [self initUI];
    [self getCompanyList];
}
- (void)loadDataAndToTop {
    currentPage = 1;
    if (self.jobTableView.contentOffset.y !=0) {
        [self.jobTableView setContentOffset:CGPointMake(0, 0) animated:YES];
    }
    [self getCompanyList];
}
- (void)getCompanyList {
    self.noDataView.hidden = YES;
    SVPHUDShow;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    dic = [UIToolsControl getPublicParameter];
    [dic setObject:recommend forKey:@"recommend"];
    [dic setObject:job_category forKey:@"job_category"];
    [dic setObject:district forKey:@"district"];
    [dic setObject:scale forKey:@"scale"];
    [dic setObject:finance forKey:@"finance"];
    [dic setObject:experience forKey:@"experience"];
    [dic setObject:education forKey:@"education"];
    [dic setObject:trade forKey:@"trade"];
    [dic setObject:wage forKey:@"wage"];
    [dic setObject:keyword forKey:@"keyword"];
    [dic setObject:lat forKey:@"lat"];
    [dic setObject:lng forKey:@"lng"];
    [dic setObject:[NSString stringWithFormat:@"%ld", (long)currentPage] forKey:@"page"];
    [dic setObject:PageSize forKey:@"number"];
    
    [BaseNetManager requestWithMethod:POST path:JobGetLists_URL params:dic successBlock:^(NSDictionary *responseObject) {
        if ([responseObject[@"code"] integerValue] == 2000) {
            id data = responseObject[@"data"];
            if ([data isKindOfClass:[NSArray class]]) {
                if (self->currentPage==1) {
                    if (self->itemDataArray.count) {
                        [self->itemDataArray removeAllObjects];
                    }
                }
                for (NSDictionary *dic in data) {
                    CompanyJobModel *model = [[CompanyJobModel alloc] init];
                    [model setValuesForKeysWithDictionary:dic];
                    [self->itemDataArray addObject:model];
                }
                self.noDataView.hidden = YES;
                [self.jobTableView.mj_footer endRefreshing];
                [self.jobTableView reloadData];
            }
            if (self->itemDataArray.count) {
            } else {
                self.noDataView.hidden = NO;
                [self.noDataView vcNilStatusType:VCNilStatusTypeOfWorkerList superView:self.view];
            }
            SVPHUDDismiss;
        } else {
            NSString *str = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            SVPHUDError(str);
        }
    } failurBlock:^(NSError *error) {
        SVPHUDError(NetErrorAlertText);
        [self.noDataView vcNilStatusType:VCNilStatusTypeOfNoNet superView:self.view];
    }];
}
- (void)initUI {
    CGRect frame = self.noDataView.frame;
    frame.origin.y += 420*Scale;
    self.noDataView.frame = frame;
    
    self.jobTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfTabBar) target:self style:UITableViewStyleGrouped];
    self.jobTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.jobTableView.rowHeight = JobCellHeight;
    [self.view addSubview:self.jobTableView];
    if (@available(iOS 11.0, *)) {
        self.jobTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    __weak __typeof(self)weakSelf = self;
    self.jobTableView.mj_footer = [MJRefreshAutoFooter footerWithRefreshingBlock:^{
        self->currentPage++;
        [weakSelf.jobTableView.mj_footer beginRefreshing];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakSelf getCompanyList];
        });
    }];
    
    //头视图
    LYRecomendView *recommendVC = [[LYRecomendView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:recomendDataArray];
    recommendVC.backBlock = ^(PublicCategoryElementModel *model) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf recomdendItemTap:model];
    };
    
    PSAreaView *areaVC = [[PSAreaView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:areaDataArray];
    areaVC.backBlcok = ^(NSDictionary * _Nullable dic) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf areaItemTap:dic];
    };
    
    LYCompanyView *companyVC = [[LYCompanyView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:companyDataArray];
    companyVC.backBlock = ^(NSArray<PublicCategoryElementModel *> *array) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf companyItemTap:array];
    };
    
    LYClaimView *claimVC = [[LYClaimView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) data:claimDataArray];
    claimVC.backBlock = ^(NSArray<PublicCategoryElementModel *> *array) {
        __strong __typeof(weakSelf)strongSelf = weakSelf;
        [strongSelf claimItemTap:array];
    };
    
    dropView = [[LYDropDownView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 44*Scale) titleArray:@[@"推荐", @"区域", @"公司", @"要求"] normalColor:THEMECOLOR_OF_TEXT_666666 selectColor:THEMECOLOR_OF_ORANGE normalImage:@"pulldown_unselect" selectImage:@"pulldown_select" dropViews:@[recommendVC, areaVC, companyVC, claimVC]];
    dropView.delegate = self;
    self.jobTableView.tableHeaderView = dropView;
    
    PersonalHomeHeaderView *tableViewHeaderView = [[PersonalHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 398*Scale) Target:self];
    tableViewHeaderView.backgroundColor = COLOR_OF_WHITE;
    dropView.headerView = tableViewHeaderView;
    
    navigationBar = [[HomeCustomNavigationBarView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HeightOfStatusBarAndNavigationBar) target:self];
    navigationBar.offsetY = 0;
    [self.view addSubview:navigationBar];
}
- (void)homeCustomNavigationBarViewQRCode {
    if (Signin) {
        QRCodeViewController *QRCVC = [[QRCodeViewController alloc] init];
        QRCVC.pushVCType = VCPushTypeOfHome;
        QRCVC.edit = ^(BOOL editFlag) {
            
        };
        QRCVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:QRCVC animated:YES];
    } else {
        [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
            
        }];
    }
}
- (void)dropDownViewTapBack {
    self.noDataView.hidden = YES;
    [self.jobTableView setContentOffset:CGPointMake(0, 325*Scale) animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (itemDataArray.count) {
        return itemDataArray.count;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    JobCell *cell = [tableView dequeueReusableCellWithIdentifier:isCellID];
    if (!cell) {
        cell = [[JobCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:isCellID];
    }
    CompanyJobModel *model = itemDataArray[indexPath.row];
    [cell reloadDataModel:model];
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    CompanyJobModel *model = itemDataArray[indexPath.row];
    JobDetailViewController *JDVC = [[JobDetailViewController alloc] init];
    JDVC.id = model.id;
    JDVC.showSettingFlag = NO;
    JDVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:JDVC animated:YES];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.00001;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.00001;
}

- (void)homeCustomNavigationBarViewFilter {
    NSLog(@"city");
    HomeFilterViewController *HFVC = [[HomeFilterViewController alloc] init];
    HFVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:HFVC animated:YES];
}
- (void)homeCustomNavigationBarViewCity {
    NSLog(@"city");
    SelcetCityViewController *SCVC = [[SelcetCityViewController alloc] init];
    SCVC.hidesBottomBarWhenPushed = YES;
    SCVC.delegate = self;
    [self.navigationController pushViewController:SCVC animated:YES];
}
- (void)selcetCityViewControllerInfo:(NSDictionary *)dic {
    if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
        [itemDataArray removeAllObjects];
    }
    if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
        district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
        navigationBar.city = dic[@"province"];
    } else {
        district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        navigationBar.city = dic[@"city"];
    }
    currentPage = 1;
    [self getCompanyList];
    
//    [NSString stringWithFormat:@"%@%@-%@%@-%@%@", dic[@"province"], dic[@"provinceid"], dic[@"city"], dic[@"cityid"], dic[@"area"], dic[@"areaid"]];
}
- (void)homeCustomNavigationBarViewSearch {
    NSLog(@"search");
    SearchJobCompanyViewController *SJCVC = [[SearchJobCompanyViewController alloc] init];
    SJCVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:SJCVC animated:YES];
}
- (void)personalHomeHeaderViewBannerCarouselTap:(NSString *)temp {
    NSLog(@"%@", temp);
}
- (void)personalHomeHeaderViewNewCarouselTap:(ArticleItemModel *)model {
    NSLog(@"new轮播");
    if (model && model.url) {
        GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
        GWVC.showType = GeneralWebViewTypeOfNews;
        GWVC.url = model.url;
        GWVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:GWVC animated:YES];
    }
}
- (void)personalHomeHeaderViewNewInvitationTap {
    GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
    GWVC.showType = GeneralWebViewTypeOfInviteFriend;
    GWVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:GWVC animated:YES];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.jobTableView) {
        navigationBar.offsetY = scrollView.contentOffset.y;
        offsetY = scrollView.contentOffset.y;
    }
}
- (void)recomdendItemTap:(PublicCategoryElementModel *)model {
    [dropView hiddenDropDownViewIndex:0];
    [self hiddenNoDataView];
    NSLog(@"--%@", model.name);
    if (recommend && (![recommend isEqualToString:model.id])) {
        [itemDataArray removeAllObjects];
    }
    recommend = model.id;
    currentPage = 1;
    [self getCompanyList];
}
//- (void)areaItemTap:(PublicCategoryElementModel *)model1 areaModel:(PublicCategoryElementModel *)model2 {
//    [dropView hiddenDropDownViewIndex:1];
//    NSLog(@"%@", [NSString stringWithFormat:@"%@-%@", model1.name, model2.name]);
//}
- (void)areaItemTap:(NSDictionary *)dic {
    [dropView hiddenDropDownViewIndex:1];
    [self hiddenNoDataView];
    if (dic && dic.allKeys.count) {
        NSString *str = [NSString stringWithFormat:@"%@%@-%@%@-%@%@", dic[@"province"], dic[@"provinceid"], dic[@"city"], dic[@"cityid"], dic[@"area"], dic[@"areaid"]];
        NSLog(@"%@", str);
        
        if (district && (![district isEqualToString:[NSString stringWithFormat:@"%@", dic[@"cityid"]]])) {
            [itemDataArray removeAllObjects];
        }
//        district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
        
        if ([[NSString stringWithFormat:@"%@", dic[@"cityid"]] integerValue] == 0) {
            district = [NSString stringWithFormat:@"%@", dic[@"provinceid"]];
            navigationBar.city = dic[@"province"];
        } else {
            district = [NSString stringWithFormat:@"%@", dic[@"cityid"]];
            navigationBar.city = dic[@"city"];
        }
        currentPage = 1;
        [self getCompanyList];
    }
}
- (void)companyItemTap:(NSArray<PublicCategoryElementModel *> *)array {
    [dropView hiddenDropDownViewIndex:2];
    [self hiddenNoDataView];
    if (array.count) {
        NSString *str = @"";
        for (PublicCategoryElementModel *model in array) {
            str = [NSString stringWithFormat:@"%@-%@", str, model.name];
            if ([model.titleName isEqualToString:@"公司规模"]) {
                if (scale && (![scale isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                scale = model.id;
            } else if ([model.titleName isEqualToString:@"融资情况"]) {
                if (finance && (![finance isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                finance = model.id;
            } else if ([model.titleName isEqualToString:@"公司行业"]) {
                if (trade && (![trade isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                trade = model.id;
            }
        }
        if (itemDataArray.count) {
            
        } else {
            currentPage = 1;
            [self getCompanyList];
        }
        NSLog(@"%@", str);
    } else {
        if (scale.length || finance.length || trade.length) {
            scale = @"";
            finance = @"";
            trade = @"";
            currentPage = 1;
            [self getCompanyList];
        }
    }
}
- (void)claimItemTap:(NSArray<PublicCategoryElementModel *> *)array {
    [dropView hiddenDropDownViewIndex:3];
    [self hiddenNoDataView];
    if (array.count) {
        NSString *str = @"";
        for (PublicCategoryElementModel *model in array) {
            str = [NSString stringWithFormat:@"%@-%@", str, model.name];
            if ([model.titleName isEqualToString:@"经验"]) {
                if (experience && (![experience isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                experience = model.id;
            } else if ([model.titleName isEqualToString:@"薪资"]) {
                if (wage && (![wage isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                wage = model.id;
            } else if ([model.titleName isEqualToString:@"学历"]) {
                if (education && (![education isEqualToString:model.id])) {
                    [itemDataArray removeAllObjects];
                }
                education = model.id;
            }
            if (itemDataArray.count) {
                
            } else {
                currentPage = 1;
                [self getCompanyList];
            }
        }
        NSLog(@"%@", str);
    } else {
        if (experience.length || wage.length || education.length) {
            experience = @"";
            wage = @"";
            education = @"";
            currentPage = 1;
            [self getCompanyList];
        }
    }
}
- (void)hiddenNoDataView {
    if (itemDataArray.count) {
        self.noDataView.hidden = YES;
    } else {
        self.noDataView.hidden = NO;
    }
}

- (void)toSignIn {
    [UIToolsControl presentSignin:self callBack:^(BOOL signinFlag) {
        if (signinFlag) {
            
        }
    }];
}
- (void)loadLocalData {
    recomendDataArray = [NSMutableArray arrayWithCapacity:0];
    areaDataArray = [NSMutableArray arrayWithCapacity:0];
    companyDataArray = [NSMutableArray arrayWithCapacity:0];
    claimDataArray = [NSMutableArray arrayWithCapacity:0];
    
    NSArray *recomendArr = @[@{@"name":@"推荐",
                               @"id":@"1"},
                             @{@"name":@"最新",
                               @"id":@"0"}];
    for (NSInteger i = 0; i < recomendArr.count; i++) {
        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
        [model setValuesForKeysWithDictionary:recomendArr[i]];
        [recomendDataArray addObject:model];
    }
    
    NSArray *areaArr = @[@{@"name":@"附近",
                           @"id":@"0",
                           @"child":@[@{@"name":@"距离不限",
                                        @"id":@"0"},
                                      @{@"name":@"1公里",
                                        @"id":@"0"},
                                      @{@"name":@"3公里",
                                        @"id":@"0"}]},
                         @{@"name":@"商圈",
                           @"id":@"0",
                           @"child":@[@{@"name":@"海淀区",
                                        @"id":@"0"},
                                      @{@"name":@"朝阳区",
                                        @"id":@"0"},
                                      @{@"name":@"通州区",
                                        @"id":@"0"}]}];
    for (NSInteger i = 0; i < areaArr.count; i++) {
        PublicCategoryElementModel *model = [[PublicCategoryElementModel alloc] init];
        [model setValuesForKeysWithDictionary:areaArr[i]];
        [areaDataArray addObject:model];
    }
    
    if ([DataToolsControl sharedManager].allCategoryInfoModel) {
        PublicCategoryElementModel *companyModel1 = [[PublicCategoryElementModel alloc] init];
        companyModel1.name = @"公司规模";
        companyModel1.id = @"1";
        companyModel1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel111 = [[PublicCategoryElementModel alloc] init];
        mmodel111.id = @"0";
        mmodel111.name = @"不限";
        mmodel111.titleName = @"公司规模";
        mmodel111.isSelect = YES;
        mmodel111.itemWidth = MAX([UIToolsControl textWidth:mmodel111.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [companyModel1.childArray addObject:mmodel111];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.scaleArray.count; i++) {
            PublicCategoryElementModel *mmodel1 = [[DataToolsControl sharedManager].allCategoryInfoModel.scaleArray[i] copy];
            mmodel1.titleName = @"公司规模";
            [companyModel1.childArray addObject:mmodel1];
        }
        [companyDataArray addObject:companyModel1];
        
        PublicCategoryElementModel *companyModel2 = [[PublicCategoryElementModel alloc] init];
        companyModel2.name = @"融资情况";
        companyModel2.id = @"2";
        companyModel2.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel222 = [[PublicCategoryElementModel alloc] init];
        mmodel222.id = @"0";
        mmodel222.name = @"不限";
        mmodel222.titleName = @"融资情况";
        mmodel222.isSelect = YES;
        mmodel222.itemWidth = MAX([UIToolsControl textWidth:mmodel222.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [companyModel2.childArray addObject:mmodel222];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.financeArray.count; i++) {
            PublicCategoryElementModel *mmodel2 = [[DataToolsControl sharedManager].allCategoryInfoModel.financeArray[i] copy];
            mmodel2.titleName = @"融资情况";
            [companyModel2.childArray addObject:mmodel2];
        }
        [companyDataArray addObject:companyModel2];
        
        PublicCategoryElementModel *companyModel3 = [[PublicCategoryElementModel alloc] init];
        companyModel3.name = @"公司行业";
        companyModel3.id = @"3";
        companyModel3.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel333 = [[PublicCategoryElementModel alloc] init];
        mmodel333.id = @"0";
        mmodel333.name = @"不限";
        mmodel333.titleName = @"公司行业";
        mmodel333.isSelect = YES;
        mmodel333.itemWidth = MAX([UIToolsControl textWidth:mmodel333.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [companyModel3.childArray addObject:mmodel333];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.tradeArray.count; i++) {
            PublicCategoryElementModel *mmodel3 = [[DataToolsControl sharedManager].allCategoryInfoModel.tradeArray[i] copy];
            mmodel3.titleName = @"公司行业";
            [companyModel3.childArray addObject:mmodel3];
        }
        [companyDataArray addObject:companyModel3];
        
        
        PublicCategoryElementModel *claimModel1 = [[PublicCategoryElementModel alloc] init];
        claimModel1.name = @"经验";
        claimModel1.id = @"4";
        claimModel1.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel444 = [[PublicCategoryElementModel alloc] init];
        mmodel444.id = @"0";
        mmodel444.name = @"不限";
        mmodel444.titleName = @"经验";
        mmodel444.isSelect = YES;
        mmodel444.itemWidth = MAX([UIToolsControl textWidth:mmodel444.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [claimModel1.childArray addObject:mmodel444];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.experienceArray.count; i++) {
            PublicCategoryElementModel *mmodel4 = [[DataToolsControl sharedManager].allCategoryInfoModel.experienceArray[i] copy];
            mmodel4.titleName = @"经验";
            [claimModel1.childArray addObject:mmodel4];
        }
        [claimDataArray addObject:claimModel1];
        
        PublicCategoryElementModel *claimModel2 = [[PublicCategoryElementModel alloc] init];
        claimModel2.name = @"薪资";
        claimModel2.id = @"5";
        claimModel2.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel555 = [[PublicCategoryElementModel alloc] init];
        mmodel555.id = @"0";
        mmodel555.name = @"不限";
        mmodel555.titleName = @"薪资";
        mmodel555.isSelect = YES;
        mmodel555.itemWidth = MAX([UIToolsControl textWidth:mmodel555.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [claimModel2.childArray addObject:mmodel555];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.wageArray.count; i++) {
            PublicCategoryElementModel *mmodel5 = [[DataToolsControl sharedManager].allCategoryInfoModel.wageArray[i] copy];
            mmodel5.titleName = @"薪资";
            [claimModel2.childArray addObject:mmodel5];
        }
        [claimDataArray addObject:claimModel2];
        
        PublicCategoryElementModel *claimModel3 = [[PublicCategoryElementModel alloc] init];
        claimModel3.name = @"学历";
        claimModel3.id = @"6";
        claimModel3.childArray = [NSMutableArray arrayWithCapacity:0];
        PublicCategoryElementModel *mmodel666 = [[PublicCategoryElementModel alloc] init];
        mmodel666.id = @"0";
        mmodel666.name = @"不限";
        mmodel666.titleName = @"学历";
        mmodel666.isSelect = YES;
        mmodel666.itemWidth = MAX([UIToolsControl textWidth:mmodel666.name size:CGSizeMake(MAXFLOAT, 30*Scale) font:Font_13]+13*Scale, ceil((WIDTH-60*Scale)/3)-1);
        [claimModel3.childArray addObject:mmodel666];
        for (NSInteger i = 0; i < [DataToolsControl sharedManager].allCategoryInfoModel.educationArray.count; i++) {
            PublicCategoryElementModel *mmodel6 = [[DataToolsControl sharedManager].allCategoryInfoModel.educationArray[i] copy];
            mmodel6.titleName = @"学历";
            [claimModel3.childArray addObject:mmodel6];
        }
        [claimDataArray addObject:claimModel3];
    }
}

@end
*/
